/*
 * @Author: your name
 * @Date: 2021-07-27 10:23:53
 * @LastEditTime: 2021-07-29 15:08:42
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \base-framework-web\src\services\common.ts
 */
import request from '@/utils/request';

//字典数据获取通用接口
export async function getStatusMap(params: string) {
  return request(`/bf/common/dict/get/${params}`, {
    method: 'get',
    // params
  });
}

// 根据指定范围加载一级机构
export async function orgGetOne(params: any) {
  return request('/bf/common/org/get_one', {
    method: 'get',
    params,
  });
}

export const formatTreeData = (data: any) => {
  if (Array.isArray(data) && data.length > 0) {
    data.forEach((ele) => {
      ele.title = ele.name;
      ele.key = ele.id;
      if (ele.children && ele.children.length > 0) {
        formatTreeData(ele.children);
      }
    });
  }
  return data;
};


// 获取登录用户信息
// userType 1:企业管理员 2：普通管理员 3：普通用户
export async function getUserMessage() {
  return request('/bf/uc/auth/user_info', {
    method: 'get',
  });
}

